package com.bruce.practice.if_refactor;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

/**
 * @author luotuan
 * @create 2019-01-09 14:07
 **/
public class OperatorFactory {
    static Map<String,Operation> operationMap = new HashMap<>();
    static {
        operationMap.put("add",new Addition());
        operationMap.put("divide",new Division());
    }
    public static Optional<Operation> getOperation(String operation){
        return Optional.ofNullable(operationMap.get(operation));
    }
}
